package main

import (
	"context"
	"fmt"
	"google.golang.org/grpc"
	v1 "user/api/user/v1"
)

var userClient v1.UserClient
var conn *grpc.ClientConn

func main() {
	Init()
	TestCreateUser()
	conn.Close()
}

func Init() {
	var err error
	conn, err = grpc.Dial("127.0.0.1:50051", grpc.WithInsecure())
	if err != nil {
		panic("Dial: " + err.Error())
	}
	userClient = v1.NewUserClient(conn)
}
func TestCreateUser() {
	user, err := userClient.GetUserById(context.Background(), &v1.IdRequest{
		Id: 5,
	})
	if err != nil {
		panic("grpc: error creating user:" + err.Error())
	}
	fmt.Println(user)
}
